﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AbilityPoints : MonoBehaviour
{
    private static AbilityPoints instance;
    public static AbilityPoints MyInstance
    {
        get
        {
            if (instance == null)
            {
                instance = FindObjectOfType<AbilityPoints>();
            }
            return instance;
        }
    }

    [SerializeField]
    private int abilityPoints;
    [SerializeField]
    private Text APTextUI;
    // Start is called before the first frame update
    void Awake()
    {
        UpdateAPTextUI();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void UpdateAPTextUI()
    {
        if (APTextUI != null)
        {
            APTextUI.text = MyAP.ToString();
            CharList.MyInstance.UpdateAPText();
        }

    }
    public int MyAP
    {
        get => abilityPoints;
        set
        {
            abilityPoints = value;
            UpdateAPTextUI();
            CharList.MyInstance.CheckButtonUsability();
        }
    }
}
